package com.ruoyi.teamSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teamSys.domain.TbManagementTeam;
import com.ruoyi.teamSys.service.ITbManagementTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 管理团队Controller
 * 
 * @author ruoyi
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/teamSys/team")
public class TbManagementTeamController extends BaseController
{
    @Autowired
    private ITbManagementTeamService tbManagementTeamService;

    @GetMapping("/public/list")
    public TableDataInfo publicList(TbManagementTeam tbManagementTeam)
    {
        startPage();
        List<TbManagementTeam> list = tbManagementTeamService.selectTbManagementTeamList(tbManagementTeam);
        return getDataTable(list);
    }

    @GetMapping(value = "/public/{id}")
    public AjaxResult publicGetInfo(@PathVariable("id") Long id)
    {
        return success(tbManagementTeamService.selectTbManagementTeamById(id));
    }
    /**
     * 查询管理团队列表
     */
    @PreAuthorize("@ss.hasPermi('teamSys:team:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbManagementTeam tbManagementTeam)
    {
        startPage();
        List<TbManagementTeam> list = tbManagementTeamService.selectTbManagementTeamList(tbManagementTeam);
        return getDataTable(list);
    }

    /**
     * 导出管理团队列表
     */
    @PreAuthorize("@ss.hasPermi('teamSys:team:export')")
    @Log(title = "管理团队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbManagementTeam tbManagementTeam)
    {
        List<TbManagementTeam> list = tbManagementTeamService.selectTbManagementTeamList(tbManagementTeam);
        ExcelUtil<TbManagementTeam> util = new ExcelUtil<TbManagementTeam>(TbManagementTeam.class);
        util.exportExcel(response, list, "管理团队数据");
    }

    /**
     * 获取管理团队详细信息
     */
    @PreAuthorize("@ss.hasPermi('teamSys:team:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbManagementTeamService.selectTbManagementTeamById(id));
    }

    /**
     * 新增管理团队
     */
    @PreAuthorize("@ss.hasPermi('teamSys:team:add')")
    @Log(title = "管理团队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbManagementTeam tbManagementTeam)
    {
        return toAjax(tbManagementTeamService.insertTbManagementTeam(tbManagementTeam));
    }

    /**
     * 修改管理团队
     */
    @PreAuthorize("@ss.hasPermi('teamSys:team:edit')")
    @Log(title = "管理团队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbManagementTeam tbManagementTeam)
    {
        return toAjax(tbManagementTeamService.updateTbManagementTeam(tbManagementTeam));
    }

    /**
     * 删除管理团队
     */
    @PreAuthorize("@ss.hasPermi('teamSys:team:remove')")
    @Log(title = "管理团队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbManagementTeamService.deleteTbManagementTeamByIds(ids));
    }
}
